package controllers;

import helpers.IdUniqueHelper;
import helpers.QuestionCrawlerHelper;
import helpers.StringHelper;

import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import debugs.CategoryDebug;

import models.CategoryModel;

import entities.Category;
import entities.Question;

import models.QuestionModel;

public class TestServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		response.getWriter().println(IdUniqueHelper.getId() + "/" + URLEncoder.encode("http://answers.yahoo.com/question/index?qid=20121207024744AAAHAVE", "UTF-8"));
		
		/*String alias = "dental";
		String id = "LT293UGMY";
		CategoryModel categoryModel = CategoryModel.getInstance();
		//Category category = categoryModel.getCategory(id);
		Category category =  categoryModel.getCategoryByAlias(alias);
		CategoryDebug.debugWeb(category, response);*/
		
		
		
		
		/*String path = ((HttpServletRequest) request).getRequestURI();
		String params = path.replaceAll(request.getServletPath() + "/", "");
		
		String[] str = params.split("/");
		String id = str[0];
		String url = URLDecoder.decode(str[1], "UTF-8");
		Question question = QuestionCrawlerHelper.getQuestion(url, id, response);*/
		
		
		/*
		try {
			request.getRequestDispatcher("/pages/question_info.jsp").forward(request, response);
		} catch (ServletException e) {
			//e.printStackTrace();
		}*/
	}
	
	public static void main(String[] args) {
		try {
			System.out.println(IdUniqueHelper.getId() + "/20121212094144AAMtUtN");
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}
}
